﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace P2PLib.Common.Command
{
    /// <summary>
    /// this is the base class of all command between 
    /// client and server
    /// </summary>
    public class CSCommandBase
    {
        //command type
        private CSCommandType type;

        public CSCommandBase(CSCommandType type)
        {
            this.type = type;
        }

        #region Property
        public CSCommandType Type
        {
            get
            {
                return type;
            }
            set
            {
                this.type = value;
            }
        }
        #endregion

        #region methods
        /// <summary>
        /// Pack the command to byte and write the byte arry 
        /// to stream
        /// </summary>
        /// <returns></returns>
        public virtual void WriteToStream(Stream stream){
            
        }

        /// <summary>
        ///read byte array from a stream and convert the 
        ///byte array to command
        /// </summary>
        public virtual void ReadFromStream(Stream stream)
        {
        }
        #endregion
    }
}
